﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Controls;
using H2.NET.Data.Common;
using H2.NET.Business;

namespace H2.NET.Web.Pages
{
    public partial class TabGroup : TaskControl
    {
        #region 属性 Public
        public MDCTabStatus Status
        {
            get
            {
                if (StoreAPI["Status~" + Key] == null)
                {
                    StoreAPI["Status~" + Key] = new MDCTabStatus();
                }
                return (MDCTabStatus)StoreAPI["Status~" + Key];
            }
            set
            {
                Key = value.KeyWord;
                StoreAPI["Status~" + Key] = value;
            }
        }

        public string Key
        {
            get
            {
                return ViewState["Key"] == null ? "" : (string)ViewState["Key"];

            }
            set { ViewState["Key"] = value; }
        }

        public int SheetIndex
        {
            get
            {
                return ViewState["SheetIndex"] == null ? 0 : (int)ViewState["SheetIndex"];

            }
            set { ViewState["SheetIndex"] = value; }
        }
        #endregion

        #region 事件 页面加载
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            InitDetails();

            if (!Page.IsPostBack)
            {
                InitControls();
            }
         }

        public void InitControls()
        {
            if (Status.Category == "GROUP")
            {
                IList<mdc_Product_Group> product_group = (List<mdc_Product_Group>)gv_Product_Group.DataSource;

                if (!Page.IsPostBack)
                {
                    gv_Product_Group.Key = Key;
                    Group_P9.Visible = true;

                    #region 发起步骤
                    if (TaskAPI.IsInitiate)
                    {
                        List<mdc_Product_Group> product_group_s = new List<mdc_Product_Group>();
                        for (int i = 0; i < 4; i++)
                        {
                            product_group_s.Add(new mdc_Product_Group());
                            product_group_s[i].No = i + 1;
                        }
                        gv_Product_Group.DataSource = product_group_s;
                    }
                    #endregion

                    #region 审批环节
                    else
                    {
                        IList<mdc_Product_Group> product_group_s = (mdc_Product_Group.process == TaskAPI.Process & mdc_Product_Group.incident == TaskAPI.Incident).List<mdc_Product_Group>();
                        if (product_group_s.Count == 0)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                product_group_s.Add(new mdc_Product_Group());
                                product_group_s[i].No = i + 1;
                            }
                        }
                        gv_Product_Group.DataSource = product_group_s;

                    }
                    #endregion
                }
            }
        }

        #endregion

        #region 事件 Add(增加行)
        protected void Add_Click(object sender, EventArgs e)
        {
            switch (((Anthem.Button)sender).ID)
            {
                case "Product_Group_Add":
                    List<mdc_Product_Group> product_group_s = (List<mdc_Product_Group>)gv_Product_Group.DataSource;
                    mdc_Product_Group product_group = new mdc_Product_Group();
                    product_group.No = product_group_s.Count + 1;
                    product_group_s.Insert(gv_Product_Group.ChangedRowIndex == -1 || gv_Product_Group.ChangedRowIndex >= product_group_s.Count ? product_group_s.Count - 1 : gv_Product_Group.ChangedRowIndex, product_group);
                    gv_Product_Group.DataSource = product_group_s;
                    gv_Product_Group.DataBind();
                    break;
            }
        }
        #endregion

        #region 方法 InitDetails(初始化明细行)
        public void InitDetails()
        {
            bool flg = Status.Marketing == "C" && TaskAPI.IsAllowSubmit;
            bool flg2 = Status.DMO == "C" && TaskAPI.IsAllowSubmit;
            bool flg3 = Status.Technical == "C" && TaskAPI.IsAllowSubmit;

            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("00", "No", BoundColumnType2.TextBox, 300, Align.Left, flg, "No", InputType.None, null));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("01", "Brand", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Brand", InputType.None, new string[12] { "", "DY, Dulux China", "MI, Maxilite China", "DR ,Dulux Pro", "IO, ICI Pro", "DM,Devoe", "CW, Cuprinol China", "LC, Levis China", "BL, Beaucolor", "GC, Glidden China", "SI, Sikkens", "PC, Packaging China" }));
            //if (TaskAPI.Process != "TW Group-Hierarchy-Cluster")
            //{
            //    gv_Product_Group.DynamicColumn.Add(new BoundColumn2("02", "Sub Line", BoundColumnType2.TextBox, 1200, Align.Left, flg, "Sub_Line", InputType.None, null));
            //}
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("03", "SKU Code", BoundColumnType2.TextBox, 1600, Align.Left, flg, "SKU_Code", InputType.None, null));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("04", "Sub Brand", BoundColumnType2.TextBox, 1000, Align.Left, flg2, "Sub_Brand", InputType.None, null));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("05", "Sub Brand Description", BoundColumnType2.TextBox, 2600, Align.Left, flg, "Sub_Brand_Description", InputType.None, null));
            //if (TaskAPI.Process == "TW Group-Hierarchy-Cluster")
            //{
            //    gv_Product_Group.DynamicColumn.Add(new BoundColumn2("06", "Product cluster(4bit)", BoundColumnType2.TextBox, 600, Align.Left, flg2, "Product_cluster", InputType.None, null));
            //    gv_Product_Group.DynamicColumn.Add(new BoundColumn2("07", "Product cluster Description(25 bit)", BoundColumnType2.TextBox, 3600, Align.Left, flg, "Product_cluster_Des", InputType.None, null));
            //}
            //if ((TaskAPI.Process !="Product Grouphiera Application"))
            //{
            //    gv_Product_Group.DynamicColumn.Add(new BoundColumn2("06", "Product Group", BoundColumnType2.TextBox, 600, Align.Left, flg2, "Product_Group", InputType.None, null));
            //    gv_Product_Group.DynamicColumn.Add(new BoundColumn2("07", "Product Group Des", BoundColumnType2.TextBox, 3600, Align.Left, flg, "Product_Group_Des", InputType.None, null));
            //}
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("08", "Prod.Category", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Prod_Category", InputType.None, new string[14] { "", "01.Interior Wall Paints/Effect coatings", "02.Lacquers/Opaques/Trimpaints", "03.Masonry Coatings", "04.Plasters/Mortars", "05.Metal Coatings", "06.Concrete Coatings", "07.Colorants", "08.Predeco *", "09.Non Paints/Applicators", "10.Translucent/Varnishes/Stains/WC *", "11.Thermal insulation", "12.Joinery Products", "13.Thinners" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("09", "Predeco", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Predeco", InputType.None, new string[10] { "", "01.Powder Filler", "02.Ready Mixed Filler", "03.Foam Filler", "04.Wood Fillers", "05.Adhesives", "06.Sealants", "07.Strippers", "08.Cleaners", "09.Other" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("10", "TVSW", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "TVSW", InputType.None, new string[8] { "", "01.No Build Wood Treatments", "02.Varnishes", "03.Wood Preservers/Treatments/Woodrestorers", "04.Low Build Wood Stains", "05.Medium/ High Build Wood Stains", "06.Wood Oils", "07.Other" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("11", "Surface", BoundColumnType2.DropDownList, 2000, Align.Left, flg, "Surface", InputType.None, new string[8] { "", "01.Wood", "02.Brick/Stone/Plaster/Gypsum", "03.Plastics", "04.Metal", "05.Concrete", "06.Universal", "07.Other " }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("12", "Main.Applic.", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Main_Applic", InputType.None, new string[12] { "", "01.Ceilings", "02.Wall's(interior)", "03.Floors", "04.Doors/Frames/Stairs", "05.Radiators", "06.Furniture (incl. garden)", "07.Masonry(exterior)", "08.Claddings", "09.Decks", "10.Fences", "11.Not applicable" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("13", "Place in sys.", BoundColumnType2.DropDownList, 4000, Align.Left, flg, "Place_in_sys", InputType.None, new string[7] { "", "01.Preserver/Pretreater", "02.Undercoat/Primer", "03.Equalizer/Smoothener", "04.Midcoat/Sealers", "05.Topcoat/Finish", "06.Not Applicable" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("14", "Technology", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Technology", InputType.None, new string[7] { "", "01.Non Paint", "02.Waterborne", "03.SB", "04.Two Components", "05.Powde", "06.Solvent free liquid" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("15", "Gloss/Sheen", BoundColumnType2.DropDownList, 2000, Align.Left, flg, "Gloss_Sheen", InputType.None, new string[5] { "", "01.Mat", "02.Satin/Midsheen", "03.Gloss", "04.Not Applicable" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("16", "Texture", BoundColumnType2.DropDownList, 3000, Align.Left, flg, "Texture", InputType.None, new string[5] { "", "01.Smooth", "02.Structured/Textured", "03.Effect", "04.Not Applicable" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("17", "Aspect", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Aspect", InputType.None, new string[5] { "", "01.Clear", "02.Opaque", "03.Translucents", "04.Not Applicable" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("18", "Interior/ext.", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Interior_ext", InputType.None, new string[5] { "", "01.Interior", "02.Exterior", "03.Interior&Exterior ", "04.Not Applicable" }));
            //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("19", "Color Prod.", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Color_Prod", InputType.None, new string[5] { "", "01.Ready Mixed White ", "02.Ready Mixed other Colors", "03.MM Basepaints", "04.Not Applicable" }));
            if (TaskAPI.Process == "Product Grouphiera Application")
            {
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("00", "No", BoundColumnType2.TextBox, 300, Align.Left, flg, "No", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("01", "Brand", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Brand", InputType.None, new string[12] { "", "DY, Dulux China", "MI, Maxilite China", "DR ,Dulux Pro", "IO, ICI Pro", "DM,Devoe", "CW, Cuprinol China", "LC, Levis China", "BL, Beaucolor", "GC, Glidden China", "SI, Sikkens", "PC, Packaging China" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("02", "Sub Line", BoundColumnType2.TextBox, 1200, Align.Left, flg, "Sub_Line", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("03", "SKU Code", BoundColumnType2.TextBox, 1600, Align.Left, flg, "SKU_Code", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("04", "Sub Brand", BoundColumnType2.TextBox, 1000, Align.Left, flg2, "Sub_Brand", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("05", "Sub Brand Description", BoundColumnType2.TextBox, 2600, Align.Left, flg, "Sub_Brand_Description", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("06", "Product Group", BoundColumnType2.TextBox, 600, Align.Left, flg2, "Product_Group", InputType.None, null));
                
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("07", "Product Group Des", BoundColumnType2.TextBox, 3600, Align.Left, flg, "Product_Group_Des", InputType.None, null));
               
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("08", "Description MSDS(EN)", BoundColumnType2.TextBox, 3600, Align.Left, flg, "MSDS_EN", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("09", "Description MSDS(CN)", BoundColumnType2.TextBox, 3600, Align.Left, flg, "MSDS_CN", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("10", "Intend use", BoundColumnType2.TextBox, 3600, Align.Left, flg, "Intend_Use", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("11", "Recipe for MSDS (DEU)", BoundColumnType2.TextBox, 3600, Align.Left, flg3, "Recipe_For_MSDS", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("12", "Prod.Category", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Prod_Category", InputType.None, new string[14] { "", "01.Interior Wall Paints/Effect coatings", "02.Lacquers/Opaques/Trimpaints", "03.Masonry Coatings", "04.Plasters/Mortars", "05.Metal Coatings", "06.Concrete Coatings", "07.Colorants", "08.Predeco *", "09.Non Paints/Applicators", "10.Translucent/Varnishes/Stains/WC *", "11.Thermal insulation", "12.Joinery Products", "13.Thinners" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("13", "Predeco", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Predeco", InputType.None, new string[10] { "", "01.Powder Filler", "02.Ready Mixed Filler", "03.Foam Filler", "04.Wood Fillers", "05.Adhesives", "06.Sealants", "07.Strippers", "08.Cleaners", "09.Other" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("14", "TVSW", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "TVSW", InputType.None, new string[8] { "", "01.No Build Wood Treatments", "02.Varnishes", "03.Wood Preservers/Treatments/Woodrestorers", "04.Low Build Wood Stains", "05.Medium/ High Build Wood Stains", "06.Wood Oils", "07.Other" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("15", "Surface", BoundColumnType2.DropDownList, 2000, Align.Left, flg, "Surface", InputType.None, new string[8] { "", "01.Wood", "02.Brick/Stone/Plaster/Gypsum", "03.Plastics", "04.Metal", "05.Concrete", "06.Universal", "07.Other " }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("16", "Main.Applic.", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Main_Applic", InputType.None, new string[12] { "", "01.Ceilings", "02.Wall's(interior)", "03.Floors", "04.Doors/Frames/Stairs", "05.Radiators", "06.Furniture (incl. garden)", "07.Masonry(exterior)", "08.Claddings", "09.Decks", "10.Fences", "11.Not applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("17", "Place in sys.", BoundColumnType2.DropDownList, 4000, Align.Left, flg, "Place_in_sys", InputType.None, new string[7] { "", "01.Preserver/Pretreater", "02.Undercoat/Primer", "03.Equalizer/Smoothener", "04.Midcoat/Sealers", "05.Topcoat/Finish", "06.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("18", "Technology", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Technology", InputType.None, new string[7] { "", "01.Non Paint", "02.Waterborne", "03.SB", "04.Two Components", "05.Powde", "06.Solvent free liquid" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("19", "Gloss/Sheen", BoundColumnType2.DropDownList, 2000, Align.Left, flg, "Gloss_Sheen", InputType.None, new string[5] { "", "01.Mat", "02.Satin/Midsheen", "03.Gloss", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("20", "Texture", BoundColumnType2.DropDownList, 3000, Align.Left, flg, "Texture", InputType.None, new string[5] { "", "01.Smooth", "02.Structured/Textured", "03.Effect", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("21", "Aspect", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Aspect", InputType.None, new string[5] { "", "01.Clear", "02.Opaque", "03.Translucents", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("22", "Interior/ext.", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Interior_ext", InputType.None, new string[5] { "", "01.Interior", "02.Exterior", "03.Interior&Exterior ", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("23", "Color Prod.", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Color_Prod", InputType.None, new string[5] { "", "01.Ready Mixed White ", "02.Ready Mixed other Colors", "03.MM Basepaints", "04.Not Applicable" }));

            }
            if (TaskAPI.Process == "TW Group-Hierarchy-Cluster")
            {
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("00", "No", BoundColumnType2.TextBox, 300, Align.Left, flg, "No", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("01", "Brand", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Brand", InputType.None, new string[3] { "", "PC, Packaging China", "PV, Packaging Inks SEAP" }));
                //gv_Product_Group.DynamicColumn.Add(new BoundColumn2("02", "SKU Code", BoundColumnType2.TextBox, 1600, Align.Left, flg, "SKU_Code", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("02", "Sub Brand", BoundColumnType2.TextBox, 1000, Align.Left, flg2, "Sub_Brand", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("03", "Sub Brand Description(35bit)", BoundColumnType2.TextBox, 2600, Align.Left, flg, "Sub_Brand_Description", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("04", "Product cluster(4bit)", BoundColumnType2.TextBox, 600, Align.Left, flg2, "Product_cluster", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("05", "Product cluster Description(25 bit)", BoundColumnType2.TextBox, 3600, Align.Left, flg, "Product_cluster_Des", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("06", "Description MSDS(EN)", BoundColumnType2.TextBox, 3600, Align.Left, flg, "MSDS_EN", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("07", "Description MSDS(ZF)", BoundColumnType2.TextBox, 3600, Align.Left, flg, "MSDS_CN", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("08", "Intend use", BoundColumnType2.TextBox, 3600, Align.Left, flg, "Intend_Use", InputType.None, null));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("09", "Recipe for MSDS (DEU)", BoundColumnType2.TextBox, 3600, Align.Left, flg3, "Recipe_For_MSDS", InputType.None, null));
                
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("10", "Prod.Category", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Prod_Category", InputType.None, new string[14] { "", "01.Interior Wall Paints/Effect coatings", "02.Lacquers/Opaques/Trimpaints", "03.Masonry Coatings", "04.Plasters/Mortars", "05.Metal Coatings", "06.Concrete Coatings", "07.Colorants", "08.Predeco *", "09.Non Paints/Applicators", "10.Translucent/Varnishes/Stains/WC *", "11.Thermal insulation", "12.Joinery Products", "13.Thinners" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("11", "Predeco", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Predeco", InputType.None, new string[10] { "", "01.Powder Filler", "02.Ready Mixed Filler", "03.Foam Filler", "04.Wood Fillers", "05.Adhesives", "06.Sealants", "07.Strippers", "08.Cleaners", "09.Other" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("12", "TVSW", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "TVSW", InputType.None, new string[8] { "", "01.No Build Wood Treatments", "02.Varnishes", "03.Wood Preservers/Treatments/Woodrestorers", "04.Low Build Wood Stains", "05.Medium/ High Build Wood Stains", "06.Wood Oils", "07.Other" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("13", "Surface", BoundColumnType2.DropDownList, 2000, Align.Left, flg, "Surface", InputType.None, new string[8] { "", "01.Wood", "02.Brick/Stone/Plaster/Gypsum", "03.Plastics", "04.Metal", "05.Concrete", "06.Universal", "07.Other " }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("14", "Main.Applic.", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Main_Applic", InputType.None, new string[12] { "", "01.Ceilings", "02.Wall's(interior)", "03.Floors", "04.Doors/Frames/Stairs", "05.Radiators", "06.Furniture (incl. garden)", "07.Masonry(exterior)", "08.Claddings", "09.Decks", "10.Fences", "11.Not applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("15", "Place in sys.", BoundColumnType2.DropDownList, 4000, Align.Left, flg, "Place_in_sys", InputType.None, new string[7] { "", "01.Preserver/Pretreater", "02.Undercoat/Primer", "03.Equalizer/Smoothener", "04.Midcoat/Sealers", "05.Topcoat/Finish", "06.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("16", "Technology", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Technology", InputType.None, new string[7] { "", "01.Non Paint", "02.Waterborne", "03.SB", "04.Two Components", "05.Powde", "06.Solvent free liquid" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("17", "Gloss/Sheen", BoundColumnType2.DropDownList, 2000, Align.Left, flg, "Gloss_Sheen", InputType.None, new string[5] { "", "01.Mat", "02.Satin/Midsheen", "03.Gloss", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("18", "Texture", BoundColumnType2.DropDownList, 3000, Align.Left, flg, "Texture", InputType.None, new string[5] { "", "01.Smooth", "02.Structured/Textured", "03.Effect", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("19", "Aspect", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Aspect", InputType.None, new string[5] { "", "01.Clear", "02.Opaque", "03.Translucents", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("20", "Interior/ext.", BoundColumnType2.DropDownList, 2600, Align.Left, flg, "Interior_ext", InputType.None, new string[5] { "", "01.Interior", "02.Exterior", "03.Interior&Exterior ", "04.Not Applicable" }));
                gv_Product_Group.DynamicColumn.Add(new BoundColumn2("21", "Color Prod.", BoundColumnType2.DropDownList, 3600, Align.Left, flg, "Color_Prod", InputType.None, new string[5] { "", "01.Ready Mixed White ", "02.Ready Mixed other Colors", "03.MM Basepaints", "04.Not Applicable" }));





            }
            SetEnable(flg, Product_Group_Add);
            SetEnable(flg, Product_Group_Delete);
        }
        #endregion

        #region 事件 Delete(删除行)
        protected void Delete_Click(object sender, EventArgs e)
        {
            switch (((Anthem.Button)sender).ID)
            {
                case "Product_Group_Delete":
                    List<mdc_Product_Group> product_group_s = (List<mdc_Product_Group>)gv_Product_Group.DataSource;
                    IList<mdc_Product_Group> list = (mdc_Product_Group.process == TaskAPI.Process & mdc_Product_Group.incident == TaskAPI.Incident).List<mdc_Product_Group>();
                    if (product_group_s.Count == 1)
                    {
                        Anthem.Manager.AddScriptForClientSideEval("JSInfomation('至少保留最后一个 Sheet ！',false)");
                        return;
                    }
                    product_group_s.RemoveAt(gv_Product_Group.ChangedRowIndex == -1 || gv_Product_Group.ChangedRowIndex >= product_group_s.Count ? product_group_s.Count - 1 : gv_Product_Group.ChangedRowIndex);
                    bool flag = false;
                    foreach (mdc_Product_Group product_group_1 in list)
                    {
                        if (string.IsNullOrEmpty(product_group_1.SKU_Code))
                        {
                            continue;
                        }
                        foreach (mdc_Product_Group product_group_2 in product_group_s)
                        {

                            if (string.IsNullOrEmpty(product_group_1.SKU_Code))
                            {
                                continue;
                            }
                            if (product_group_2.ID == product_group_1.ID)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            Storage.Delete(product_group_1);
                        }
                        flag = false;
                    }

                    gv_Product_Group.DataSource = product_group_s;
                    gv_Product_Group.DataBind();
                    break;
            }
        }
        #endregion

        #region 方法 Save(保存数据库)
        public void Save()
        {
            if (!Status.IsEdited)
            {
                return;
            }

            switch (Status.Category)
            {

                #region Group
                case "GROUP":
                    foreach (mdc_Product_Group product_group in (List<mdc_Product_Group>)gv_Product_Group.DataSource)
                    {
                        //if (string.IsNullOrEmpty(product_group.Sub_Line))
                        //{
                        //    continue;
                        //}
                        product_group.Process = TaskAPI.Process;
                        product_group.Incident = TaskAPI.Incident;
                        product_group.UserName = UserAPI.UserName;
                        product_group.Time = System.DateTime.Now;
                        product_group.Status = 0;
                        Storage.Save(product_group);
                    }
                    break;
                #endregion
            }
        }
        #endregion

        #region 方法 DataValidation(数据验证)
        public List<string> DataValidation()
        {
            //如果当前 Tabs 是隐藏的情况，退出
            //if (!Status.IsEdited)
            //{
            //    return new List<string>();
            //}

            List<string> vald_s = new List<string>();
            List<Regular> regs = new List<Regular>();


            vald_s.AddRange(Validation(regs));

            if (vald_s.Count > 0)
            {
                vald_s.Insert(0, "<font color='#0000FF'><b>" + Status.Name + "</b></font>");
                vald_s.Add("&nbsp;&nbsp;-----------------------------------------");
            }

            return vald_s;
        }
        #endregion
    }
}